﻿package
{
	import fr.digitas.flowearth.debug.FPS;
	import flash.display.InteractiveObject;
	import fr.digitas.flowearth.ui.layout.utils.IInterpolable;
	import flash.events.MouseEvent;
	import flash.display.StageScaleMode;
	import flash.display.StageAlign;
	import flash.events.Event;
	import flash.display.Sprite;

	
	public class Main extends Sprite
	{
		
		// __________________________________________________________
		// -										 	  CONSTRUCTOR
		public function Main()
		{
			if (stage)
				_init();
			else
				addEventListener(Event.ADDED_TO_STAGE, _init);
		}

		// __________________________________________________________
		// -										 			 INIT
		private function _init(event : Event=null) : void
		{
			_initStage();
			_build();
		}
		private function _initStage() : void
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
		}

		private function _build() : void
		{
			var bt:Sprite = new Sprite();
			
			bt.graphics.beginFill(0);
			bt.graphics.drawRect(0, 100, 20, 20);
			bt.graphics.endFill();
			addChild(bt);
			
			bt.addEventListener(MouseEvent.CLICK, _onClick);
			
			addChild(new FPS());
		}

		private function _onClick(event : MouseEvent) : void
		{
			InteractiveObject(event.target).removeEventListener(MouseEvent.CLICK, _onClick);
			
			var t:SliceBmp = new SliceBmp(new MyBmpData_FC());
			t.x =t.y = 200;
			addChild(t);
			
		}
	}
}
